layui.define([ 'form', 'laydate', 'table','ruleApi' ], function(exports) {
	var form = layui.form;
	var laydate = layui.laydate;
	var table = layui.table;
	var ruleApi = layui.ruleApi;
	var rechargeTable = null;
	
	var view ={
		
		init:function(){
			this.initTable();
			this.initSearchForm();
			this.initToolBar();
			window.dataReload = function(){
				Lib.doSearchForm($("#searchForm"),rechargeTable)
			}
			
			
		},
		initTable:function(){
			rechargeTable = table.render({
				elem : '#rechargeTable',
				height : Lib.getTableHeight(2),
				method : 'post',
				url : Common.ctxPath + '/admin/rule/list.json' //数据接口
				,page : Lib.tablePage //开启分页
				,limit : 10,
				cols : [ [ //表头
				{
					type : 'checkbox',
					fixed:'left',
				}, {
					field : 'openid',
					title : '用户ID',
					width : 280,
					fixed:'center',
					sort : true
				}, {
					field : 'nickname',
					title : '微信昵称',
					width : 120
				}, {
					field : 'loginScore',
					title : '注册透镜分',
					width : 150
				}, {
					field : 'directScore',
					title : '直荐透镜分',
					width : 120
				}, {
					field : 'indirectScore',
					title : '转荐透镜分',
					width : 120
				},{
                        field : 'updator',
                        title : '更新人',
                        width : 120
				},{
					field : 'updateTime',
					title : '更新时间',
					width : 120,
					templet:function(d){
						return Common.getDate(d.updateTime);
					},
					sort : true
				}

				] ]

			});
		},
		
		initSearchForm:function(){
			Lib.initSearchForm( $("#searchForm"),rechargeTable,form);
		},
		initToolBar:function(){
			toolbar = {
					edit:function() { //获取选中数目
						var data = Common.getOneFromTable(table,"rechargeTable");
						if(data==null){
							return ;
						}
						var url = "/admin/rule/edit.do?openid="+data.openid;
						Common.openDlg(url,"透镜分规则管理>配置");
					},
					del : function() {
						layui.use(['del'], function(){
							var delView = layui.del
							delView.delBatch();
						});
					}
				};
			$('.ext-toolbar').on('click', function() {
				var type = $(this).data('type');
				toolbar[type] ? toolbar[type].call(this) : '';
			});
		}
	}

		 exports('index',view);
	
});